package cn.ekuma.util;

import java.util.Arrays;

/**
 * Created by wushunlian on 15/7/5.
 */
public class EANCodeUtil {
    public static int CodeType_EAN8=0;
    public static int CodeType_EAN13=2;


    public static String getRoundCode(int type){
          return null;
    }


    public static String calcEANCRC(String inCode){
        char[] ean=inCode.toCharArray();
        int c1=0;
        int c2=0;
        for(int i=0;i<ean.length;i+=2){
            int ch1=ean[i]-'0';
            c1+=ch1;
            int ch2=ean[i+1]-'0';
            c2+=ch2;
        }
        int cc=c1+3*c2;
        int check=(10-cc%10)%10;
        ean = Arrays.copyOf(ean, ean.length + 1);
        ean[ean.length-1]=(char)(check+'0');
        return ean.toString();
    }
}
